#include<iostream>
#include<thread>
#include<future>
extern int Add(int num1,int num2);


int main()
{
//std:;async(func,.....) std::async(policy,func,.....)
std::cout<<"------------1------------\n";
//std::launch::deferred 在执行get获取一步操作结果时，才会执行一步任务
//s特点::lanuch::async 内部会创建工作线程，异步完成任务

std::future<int> result=std::async(std::launch::async,Add,11,12);
std::this_thread::sleep_for(std::chrono::seconds(10));
std::cout<<"------------2-------------\n";
int sum=result.get();
std::cout<<"------------3-------------\n";
std::cout<<sum<<std::endl;
    return 0;
}

int Add(int num1,int num2)
{
    std::cout<<"加法！！！！1111\n";
    std::this_thread::sleep_for(std::chrono::seconds(10));
    std::cout<<"加法！！！！2222\n";
    return num1+num2;
}